

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaaem">
    <el-row>
    <el-col :span="12">
    <!-- {"index":107,"raw":"doc_name","name":"doc_name","cname":"DocName","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["bq","l","c","u","le","q","v","DN","#like"],"desc":{"raw":"名称","name":"名称"}} -->
    <!--名称 输入控件 -->
    <el-form-item prop="doc_name" label="名称" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.doc_name"  maxlength="32" 
      :rows="0"  placeholder="请输入名称"  />
      </el-form-item>
    </el-col>
    <el-col :span="12">
    <!-- {"index":108,"raw":"doc_type","name":"doc_type","cname":"DocType","type":{"raw":"varchar2(32)","name":"varchar2","len":32,"dlen":0},"defValue":"","allowNull":false,"constraints":["bq","l","c","u","le","q","fq","v","sl","tp(xtabs,q,doc_type)"],"desc":{"raw":"类型","name":"类型"}} -->
     <!--类型 下拉控件 -->
    <el-form-item prop="doc_type" label="类型" label-width="100px" label-position="right">
      <el-select   v-model="form.doc_type" style="width: 100%" filterable clearable
        placeholder="请选择类型" >
        <el-option v-for="item in doc_typeList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":111,"raw":"url","name":"url","cname":"Url","type":{"raw":"varchar2(255)","name":"varchar2","len":255,"dlen":0},"defValue":"","allowNull":false,"constraints":["l","le","c","u","v","rows(1)","tp(link,l-le-v)","tp(file,c-u)"],"desc":{"raw":"文档链接","name":"文档链接"}} -->
    <!--文档链接 文件控件 -->
    <el-form-item prop="url" label="文档链接" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.url"  maxlength="255" 
        :rows="1"   show-word-limit 
        placeholder="请输入文档链接地址或上传文件"  >
        <template #append>
          <el-upload multiple :show-file-list="false" :action="conf.uploadPath" :limit="100" :on-success="onUploadSuccess" >
            <el-button type="primary">选择文件</el-button>
          </el-upload>
        </template>
      </el-input>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":112,"raw":"memo","name":"memo","cname":"Memo","type":{"raw":"varchar2(128)","name":"varchar2","len":128,"dlen":0},"defValue":"","allowNull":true,"constraints":["le","c","u","v","rows(8)","l","show(m,l)"],"desc":{"raw":"说明","name":"说明"}} -->
    <!--说明 输入控件 -->
    <el-form-item prop="memo" label="说明" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.memo"  maxlength="128" 
      :rows="8"  type="textarea" show-word-limit  placeholder="请输入说明"  />
      </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改文档",
rules_aaaem:{
    doc_name:[{required:true,message:"请输入名称",trigger: 'blur'}],
    doc_type:[{required:true,message:"请输入类型",trigger: 'blur'}],
    url:[{required:true,message:"请输入文档链接",trigger: 'blur'}],
    memo:[{required:false,message:"请输入说明",trigger: 'blur'}],
  },
    form:{
        doc_name:"",
        doc_type:"",
        url:"",
        memo:"",
    },
    doc_typeList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaaem()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.doc_id = form.doc_id
        this.$theia.http.get("/ws/dev/docs",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaaem()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `文档查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/ws/dev/docs",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '文档保存成功',duration:5000})
            that.$theia.enum.clear("dev_docs")
            that.$theia.enum.get("dev_docs")
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `文档修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
      this.form.url = response.path
    },
    loadEnums_aaaem(){
        //类型
        this.doc_typeList = this.$theia.enum.get("doc_type","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>